#include <iostream>
class Person
{
public:
    Person(int age) : age(age) {}

public:
    int age;
};

template <typename num1, typename num2>
num1 add(num1 a, num2 b)
{
    num1 c = a + b;
    std::cout << c << std::endl;
    return c;
}
int add(int a, int b)
{
    std::cout << "调用普通函数\n";
    return a + b;
}

template <typename type1, typename type2>
int compare(type1 a, type2 b)
{
    return a - b;
}
/*函数模版重载*/
template <>
int compare<Person>(Person p1, Person p2)
{
    return p1.age - p2.age;
}

// int operator-(const Person &p1, const Person &p2)
// {
//     return p1.age - p2.age;
// }

/*函数模板和普通函数冲突时优先调用普通函数*/
int main()
{
    Person p1(19);
    Person p2(22);

    std::cout << compare(p1, p2) << std::endl;
}